package ie.ul.breakthrough;


/**
 * This extends the abstract player class defined earlier. It is an
 * implementation that prompts a human player for a move.
 *
 */
public class HumanPlayer extends Player {

	/**
	 * Blank class constructor
	 *
	 */
	public HumanPlayer() {}

	/**
	 * Constructor that uses the name from the superclass
	 * @param pName A String with the name of the player
	 */
	public HumanPlayer(String pName) {super(pName);}

	/**
	 * Extended initialize function. Takes a side
	 * for the player
	 * @param pColour A char that sets the side the player is on. 'b' for black,
	 * and 'w' for white
	 */
	public void initialize(char pColour) {
		colour = pColour;
	}

	/**
	 * Makes a move. In this implementation, this
	 * gets to human player to input a move.
	 */
	public BreakthroughMove makeMove(Breakthrough game) {
		// Initialize the array. The arrays are all templates (generics)
		// so for good practice, they are set to their type inside
		// the angled brackets. In this case the type is BreakthroughMove.
	//	ArrayList<BreakthroughMove> possibleMoves = new ArrayList<BreakthroughMove>();
		// Get the list of possible moves
	//	possibleMoves = game.generateMoves(colour);



		String sInput = getInput("Enter r1, c1, r2, c2 (or -1 to concede)");

		// If the game is conceded
		if (sInput.indexOf("-1") != -1) {
			BreakthroughMove gameOver = new BreakthroughMove(0,0,0,0);
			gameOver.lostGame();
			return gameOver;
		}
		// otherwise
		String [] splitInput = sInput.split(",");

		Integer ir1 = new Integer(splitInput[0].trim());
		Integer ic1 = new Integer(splitInput[1].trim());
		Integer ir2 = new Integer(splitInput[2].trim());
		Integer ic2 = new Integer(splitInput[3].trim());

		BreakthroughMove humanMove = new BreakthroughMove(ir1.intValue(),
											  ic1.intValue(),
											  ir2.intValue(),
											  ic2.intValue());
		return humanMove;

	}
}